package com.football.springboot.common;

import java.util.HashMap;
import java.util.Map;


//接口统一返回数据包装类
public class Return extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;

	private String code;
	private String msg;
	private Object data;

	public Return() {
		put("code", 0);
	}

	public Return(String code200, String s, Object data) {
	}

	
	public static Return error(String msg) {
		return error(500, msg);
	}
	
	public static Return error(int code, String msg) {
		Return r = new Return();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}


	public static Return ok(String msg) {
		Return r = new Return();
		r.put("msg", msg);
		return r;
	}
	
	public static Return ok(Map<String, Object> map) {
		Return r = new Return();
		r.putAll(map);
		return r;
	}
	public static Return ok() {
		return new Return();
	}

	public Return put(String key, Object value) {
		super.put(key, value);
		return this;
	}

	public static Return success() {
		return new Return(Constants.CODE_200, "", null);
	}

	public static Return success(Object data) {
		return new Return(Constants.CODE_200, "", data);
	}

	public static Return error(String code, String msg) {
		return new Return(code, msg, null);
	}

	public static Return error() {
		return new Return(Constants.CODE_500, "系统错误", null);
	}
}
